package com.wft;

public class Solution258 {
    public static void main(String[] args) {
        int num = 12123;
        System.out.println(addDigits(num));

        System.out.println(num%9);
    }

    public static int addDigits(int num) {
        int temp;
        while (num > 9) {
            temp = 0;
            while(num >9){
                temp += num%10;
                num/=10;
            }
            temp += num%10;
            num = temp;
        }
        return num;
    }
}
